from django.db import models


# Create your models here.

class UserModel(models.Model):
    username = models.CharField(max_length=32, verbose_name="用户名")
    password = models.CharField(max_length=256, verbose_name="密码")
    mobile = models.CharField(max_length=11, verbose_name="手机号")

    class Meta:
        db_table = "user"


class AddressModel(models.Model):
    default_text = (
        (True, "默认地址",),
        (False, "非默认",),
    )
    name = models.CharField(max_length=32, verbose_name="收货人")
    mobile = models.CharField(max_length=32, verbose_name="联系方式")
    addr = models.CharField(max_length=256, verbose_name="收货地址")
    is_default = models.BooleanField(default=False, choices=default_text, verbose_name="是否默认地址")
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE, verbose_name="所属用户")

    class Meta:
        db_table = "address"
